/*------------------------------------------------------------------------------
 * PROJ : Prototype
 * NAME : sculove.spring.framework.advice.BizExceptionAdvice.java
 *        
 * Copyright 2009 sculove All rights reserved
 *------------------------------------------------------------------------------
*/
package sculove.spring.framework.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.web.servlet.ModelAndView;

import sculove.spring.framework.exception.BizException;
import sculove.spring.framework.util.Configuration;
/**
 * <pre>
 * sculove.spring.framework.advice.BizExceptionAdvice.java
 * 
 * BizException
 * 
 * </pre>
 * @date : 2009. 12. 29. 오후 5:55:59
 * @version :
 * @author : sculove
 */
public class BizExceptionAdvice implements MethodInterceptor {

	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		Object returnVal = null;
		try {
			returnVal = invocation.proceed();
		} catch (BizException e) {
			ModelAndView mv = new ModelAndView();
			mv.setViewName(e.getViewName());
			mv.addObject(Configuration.getPropInstance().getString("com.message.code"),e.getMessageCode());
			mv.addObject(Configuration.getPropInstance().getString("com.message.arguments"),e.getMessageArguments());
			return mv;
		} catch (Exception e) {
			throw e;
		}
		return returnVal;
	}
}
